package com.maimao.model.goods.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

/**
 * @author MaoLin Wang
 * @date 2021/1/30 11:18 上午
 */
@Getter
public enum CommentType {
    /**
     * 回复类型评论
     */
    REPLY(0, "讨论"),
    GOOD(1, "好评"),
    NOT_GOOD(2, "中评"),
    BAD(3, "差评"),
    /**
     * 仅统计图表时使用
     */
    ALL(-1, "全部"),

    ;

    CommentType(Integer type, String msg) {
        this.type = type;
        this.desc = msg;
    }

    private Integer type;

    private String desc;

    public static String getMsgByCode(Integer type) {
        if (ObjectUtil.isNull(type)) {
            return null;
        }
        for (CommentType value : values()) {
            if (value.getType().equals(type)) {
                return value.getDesc();
            }
        }
        return null;
    }
}
